//    Copyright (C) Kherty.  All rights reserved.
using System.Windows;
using System.Windows.Controls;
using OpenLS.Spreadsheet.Internals;
using System.Windows.Media;

namespace OpenLS.Spreadsheet.UI
{
    partial class GroupResources
    {
        public GroupResources()
        {
            InitializeComponent();
        }

        private void b_Click(object sender, RoutedEventArgs e)
        {
            var group = (ChildGroup) ((FrameworkElement) sender).DataContext;
            group.IsExpanded = !group.IsExpanded;
            e.Handled = true;
        }
        private void outlineButtonClick(object sender, RoutedEventArgs e)
        {
            RootGroup group = null;
            var element = (FrameworkElement) sender;
            while (e != null)
            {
                group =  element.Tag as RootGroup;
                if (group != null)
                    break;
                element = (FrameworkElement) VisualTreeHelper.GetParent(element);
            }
            int depth = (int) ((Button) sender).Content;
            group.Expand(depth);

        }
    }
}
